package com.deyuanyun.pic.pipe.controller.vo.merge;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.util.format.NumberFormat;
import com.deyuanyun.pic.pipe.controller.vo.BaseVOUtil;
import com.deyuanyun.pic.pipe.domain.bo.MarkerMergeBO;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

/**
 * 埋地标识信息表
 */
public class MarkerMergeVO {

    // 主键
    private String id;
    // 管道名称
    private String pipeLineName;
    // 标识器编号
    private String markerNumber;
    // 标识类型
    private String markerType;
    // 绝对距离(m)
    private String mileage;
    // 相对最近参考点
    private String reference;
    // 相对最近参考点距离(m)
    private String referenceDistance;
    // gis地图
    private String gisId;
    // 类型：0，埋地标识；1，埋地标识_警示带、警示板
    private String mergeType;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getMarkerNumber() {
        return markerNumber;
    }

    public void setMarkerNumber(String markerNumber) {
        this.markerNumber = markerNumber;
    }

    public String getMarkerType() {
        return markerType;
    }

    public void setMarkerType(String markerType) {
        this.markerType = markerType;
    }

    public String getMileage() {
        return mileage;
    }

    public void setMileage(String mileage) {
        this.mileage = mileage;
    }

    public String getReference() {
        return reference;
    }

    public void setReference(String reference) {
        this.reference = reference;
    }

    public String getReferenceDistance() {
        return referenceDistance;
    }

    public void setReferenceDistance(String referenceDistance) {
        this.referenceDistance = referenceDistance;
    }

    public String getGisId() {
        return gisId;
    }

    public void setGisId(String gisId) {
        this.gisId = gisId;
    }

    public String getMergeType() {
        return mergeType;
    }

    public void setMergeType(String mergeType) {
        this.mergeType = mergeType;
    }

    public void fromDomain(MarkerMergeBO domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }

        // 主键
        this.id = domain.getId();
        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 标识器编号
        this.markerNumber = domain.getMarkerNumber();
        // 标识类型
        this.markerType = CodeUtil.getName(domain.getMarkerType());
        // 绝对距离(m)
        this.mileage = NumberFormat.format(domain.getMileage(), NumberFormat.FMT_PLACES3);
        // 相对最近参考点
        this.reference = domain.getReference();
        // 相对最近参考点距离(m)
        this.referenceDistance = NumberFormat.format(domain.getReferenceDistance(), NumberFormat.FMT_PLACES3);
        // 类型：0，埋地标识；1，埋地标识_警示带、警示板
        this.mergeType = domain.getMergeType();
        // gis地址
        this.gisId = domain.getGisId();
    }

    public Page<MarkerMergeVO> fromDomainList(Page<MarkerMergeBO> domainList) {
        Page<MarkerMergeVO> list = new Page<MarkerMergeVO>();
        for (MarkerMergeBO markerMergeBO : domainList) {
            MarkerMergeVO markerMergeVO = new MarkerMergeVO();
            markerMergeVO.fromDomain(markerMergeBO);
            list.add(markerMergeVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}